package com.example.day04;

import com.example.day03.ConstantEnumIFace;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @author jeff
 * @since 2023/5/1 11:46
 */
public class ConstantEnumJsonSerializer extends JsonSerializer<ConstantEnumIFace> {

    @Override
    public void serialize(ConstantEnumIFace constantEnum, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        System.out.println("正在执行serialize方法:"+constantEnum+"，value:"+constantEnum.getValue());
        jsonGenerator.writeNumber(constantEnum.getValue());
        System.out.println("json写入完成");

    }
}
